home *** CD-ROM | disk | FTP | other *** search
/ Professional Soft Collection 1.02 / Professional Soft Collection 1.02.iso / archivat / arj250.exe / TECHNOTE.DOC < prev    next >
Text File  |  1995-10-31  |  10KB  |  245 lines

  1.  
  2.      ARJ TECHNICAL INFORMATION                                October 1995
  3.  
  4.  
  5.      ** IMPORTANT NEWS ****************************************************
  6.  
  7.      Some archiver support programs have designed ARJ archive
  8.      identification schemes that are not reliable.  At ARJ 2.39, there
  9.      are now two versions of the ARJSFX self-extraction module.  The 18K
  10.      byte ARJSFX module supports ARJ-SECURITY.  The standard 16K byte
  11.      ARJSFX module does NOT support ARJ-SECURITY.  At ARJ 2.50, there is
  12.      a new ARJSFXV multiple volume self-extraction module.  For the
  13.      first time, the ARJ-SECURITY fields in the main ARJ header are
  14.      publicly defined.
  15.  
  16.      In addition, the main ARJ header in self-extracting archives MAY NOT
  17.      immediately follow the EXE module now.
  18.  
  19.      ARJ has used the same ARJ archive identification scheme since ARJ
  20.      1.0.  The following is the algorithm:
  21.  
  22.      (1) find the ARJ header id bytes 0x60, 0xEA,
  23.      (2) read the next two bytes as the header record size in bytes,
  24.      (3) if the record size is greater than 2600, go back to the header
  25.      id file position, increment the file position, and go back to
  26.      step (1),
  27.      (4) read the header record based upon the previous byte count,
  28.      (5) calculate the 32 bit CRC of the header record data,
  29.      (6) read the next four bytes as the actual header record CRC,
  30.      (7) if the actual CRC does not equal the calculated CRC, go back
  31.      to the header id file position, increment the file position,
  32.      and go back to step (1).
  33.  
  34.      It is acceptable to start this identification algorithm at a point
  35.      just after the ARJ self-extraction EXE portion of an archive.  This
  36.      algorithm is fully demonstrated in the UNARJ C source code. A portion
  37.      of that source code is excerpted at the end of this document.
  38.  
  39.      As of ARJ 2.10, the SFX executable modules are pre-compressed
  40.      using LZEXE.  This may cause false indications with EXE scanning
  41.      programs showing that an ARJ SFX archive is a LZEXE compressed
  42.      file.  Only the executable header module is LZEXE compressed.
  43.      The actual archive is ARJ compressed, of course.  The LZEXE
  44.      header is modified to avoid extraction by UNLZEXE type programs.
  45.      UNLZEXE may truncate an ARJ self-extractor of its archive.
  46.  
  47.      All SFX modules have an identification string located in the
  48.      first 1000 characters of the executable.  The identification
  49.      string is "aRJsfX" without the quotes and in the exact case.
  50.  
  51.      When using listfiles with ARJ, ARJ support programs should use the
  52.      "-p" option to ensure that ARJ will only extract the selected files
  53.      from an ARJ archive.  In addition, the listfiles should contain the
  54.      full pathname information as stored in the ARJ archive.  This avoids
  55.      the problem accessing files that have the same filename but different
  56.      paths.
  57.  
  58.      There is an extended header bug in older versions of ARJ, AV.C and
  59.      UNARJ.C.  The extended header processing in read_header() should
  60.      skip 4 bytes for the extended header CRC and not 2.  This is NOT a
  61.      current problem as no versions of ARJ use the extended header.
  62.  
  63.      **********************************************************************
  64.  
  65.  
  66.      Modification history:
  67.      Date      Description of modification:
  68.      --------  ------------------------------------------------------------
  69.      07/07/95  Added information about SFX id string.
  70.      11/03/94  Improved SFX identification information.
  71.      01/21/94  Added find_header() routine.
  72.      03/17/93  Added information about ARJSFX change.
  73.      02/17/93  Added description of ARJ security fields.
  74.            Added archive date-modified field.
  75.      12/03/91  Added BACKUP flag to header arj flags.
  76.      11/21/91  Described the two types of headers separately.
  77.      11/11/91  Added information about the change in text mode processing.
  78.      06/28/91  Added several new HOST OS numbers.
  79.      05/19/91  Improved the description of extended header processing.
  80.      05/11/91  Simplified this document.  Added volume label type.
  81.      03/11/91  Added directory file type.
  82.      02/23/91  Added more comments.
  83.      01/10/91  Corrected timestamp description and header order of file mode.
  84.      10/30/90  Corrected values of flags in ARJ flags.
  85.  
  86.  
  87.      ARJ archives contains two types of header blocks:
  88.  
  89.     Archive main header - This is located at the head of the archive
  90.     Local file header   - This is located before each archived file
  91.  
  92.      Structure of main header (low order byte first):
  93.  
  94.      Bytes Description
  95.      ----- -------------------------------------------------------------------
  96.        2   header id (main and local file) = 0x60 0xEA
  97.        2   basic header size (from 'first_hdr_size' thru 'comment' below)
  98.          = first_hdr_size + strlen(filename) + 1 + strlen(comment) + 1
  99.          = 0 if end of archive
  100.          maximum header size is 2600
  101.  
  102.        1   first_hdr_size (size up to and including 'extra data')
  103.        1   archiver version number
  104.        1   minimum archiver version to extract
  105.        1   host OS   (0 = MSDOS, 1 = PRIMOS, 2 = UNIX, 3 = AMIGA, 4 = MAC-OS)
  106.              (5 = OS/2, 6 = APPLE GS, 7 = ATARI ST, 8 = NEXT)
  107.              (9 = VAX VMS)
  108.        1   arj flags
  109.              (0x01 = NOT USED)
  110.              (0x02 = OLD_SECURED_FLAG)
  111.              (0x04 = VOLUME_FLAG)  indicates presence of succeeding
  112.                        volume
  113.              (0x08 = NOT USED)
  114.              (0x10 = PATHSYM_FLAG) indicates archive name translated
  115.                        ("\" changed to "/")
  116.              (0x20 = BACKUP_FLAG) indicates backup type archive
  117.              (0x40 = SECURED_FLAG)
  118.        1   security version (2 = current)
  119.        1   file type        (must equal 2)
  120.        1   reserved
  121.        4   date time when original archive was created
  122.        4   date time when archive was last modified
  123.        4   archive size (currently used only for secured archives)
  124.        4   security envelope file position
  125.        2   filespec position in filename
  126.        2   length in bytes of security envelope data
  127.        2   (currently not used)
  128.        ?   (currently none)
  129.  
  130.        ?   filename of archive when created (null-terminated string)
  131.        ?   archive comment  (null-terminated string)
  132.  
  133.        4   basic header CRC
  134.  
  135.        2   1st extended header size (0 if none)
  136.        ?   1st extended header (currently not used)
  137.        4   1st extended header's CRC (not present when 0 extended header size)
  138.  
  139.  
  140.      Structure of local file header (low order byte first):
  141.  
  142.      Bytes Description
  143.      ----- -------------------------------------------------------------------
  144.        2   header id (main and local file) = 0x60 0xEA
  145.        2   basic header size (from 'first_hdr_size' thru 'comment' below)
  146.          = first_hdr_size + strlen(filename) + 1 + strlen(comment) + 1
  147.          = 0 if end of archive
  148.          maximum header size is 2600
  149.  
  150.        1   first_hdr_size (size up to and including 'extra data')
  151.        1   archiver version number
  152.        1   minimum archiver version to extract
  153.        1   host OS   (0 = MSDOS, 1 = PRIMOS, 2 = UNIX, 3 = AMIGA, 4 = MAC-OS)
  154.              (5 = OS/2, 6 = APPLE GS, 7 = ATARI ST, 8 = NEXT)
  155.              (9 = VAX VMS)
  156.        1   arj flags (0x01 = GARBLED_FLAG) indicates passworded file
  157.              (0x02 = NOT USED)
  158.              (0x04 = VOLUME_FLAG)  indicates continued file to next
  159.                        volume (file is split)
  160.              (0x08 = EXTFILE_FLAG) indicates file starting position
  161.                        field (for split files)
  162.              (0x10 = PATHSYM_FLAG) indicates filename translated
  163.                        ("\" changed to "/")
  164.              (0x20 = BACKUP_FLAG)  indicates file marked as backup
  165.        1   method    (0 = stored, 1 = compressed most ... 4 compressed fastest)
  166.        1   file type (0 = binary,    1 = 7-bit text)
  167.              (3 = directory, 4 = volume label)
  168.        1   reserved
  169.        4   date time modified
  170.        4   compressed size
  171.        4   original size (this will be different for text mode compression)
  172.        4   original file's CRC
  173.        2   filespec position in filename
  174.        2   file access mode
  175.        2   host data (currently not used)
  176.        ?   extra data
  177.        4 bytes for extended file starting position when used
  178.        (these bytes are present when EXTFILE_FLAG is set).
  179.        0 bytes otherwise.
  180.  
  181.        ?   filename (null-terminated string)
  182.        ?   comment  (null-terminated string)
  183.  
  184.        4   basic header CRC
  185.  
  186.        2   1st extended header size (0 if none)
  187.        ?   1st extended header (currently not used)
  188.        4   1st extended header's CRC (not present when 0 extended header size)
  189.  
  190.        ...
  191.  
  192.        ?   compressed file
  193.  
  194.  
  195.      Time stamp format:
  196.  
  197.     31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
  198.        |<---- year-1980 --->|<- month ->|<--- day ---->|
  199.  
  200.     15 14 13 12 11 10  9  8  7  6  5  4  3    2  1  0
  201.        |<--- hour --->|<---- minute --->|<- second/2 ->|
  202.  
  203.  
  204.      Routine to find an ARJ Header record:
  205.  
  206.        long find_header(FILE *fd)
  207.        {
  208.            long arcpos, lastpos;
  209.            int c;
  210.  
  211.            arcpos = file_tell(fd);
  212.            file_seek(fd, 0L, SEEK_END);
  213.            lastpos = file_tell(fd) - 2;
  214.            for ( ; arcpos < lastpos; arcpos++)
  215.            {
  216.                file_seek(fd, arcpos, SEEK_SET);
  217.                c = fget_byte(fd);
  218.                while (arcpos < lastpos)
  219.                {
  220.                    if (c != HEADER_ID_LO)  /* low order first */
  221.                        c = fget_byte(fd);
  222.                    else if ((c = fget_byte(fd)) == HEADER_ID_HI)
  223.                        break;
  224.                    arcpos++;
  225.                }
  226.                if (arcpos >= lastpos)
  227.                    break;
  228.                if ((headersize = fget_word(fd)) <= HEADERSIZE_MAX)
  229.                {
  230.                    crc = CRC_MASK;
  231.                    fread_crc(header, (int) headersize, fd);
  232.                    if ((crc ^ CRC_MASK) == fget_crc(fd))
  233.                    {
  234.                        file_seek(fd, arcpos, SEEK_SET);
  235.                        return arcpos;
  236.                    }
  237.                }
  238.            }
  239.            return -1;          /* could not find a valid header */
  240.        }
  241.  
  242.  
  243.      end of document
  244.  
  245.